package com.ryskoo.catering.coupon.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.coupon.domain.CouponPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class CouponRedisImpl extends BasicRedisImpl<CouponPO> implements ICouponRepository{

    private static final String cacheKey = HCLCacheConstant.HCL_COUPON_KEY;

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private ICouponRepository couponRepository;

    @PostConstruct
    public void init() {
        this.setRedisClient(redisClient);
        this.setDao(couponRepository);
    }

    public CouponRedisImpl() {
        super(cacheKey);
    }

    @Override
    public List<CouponPO> getListForVendorByVendorUuid(String vendorUuid) {
        return couponRepository.getListForVendorByVendorUuid(vendorUuid);
    }
}
